Simplified the code, removed checkbox and moved section further down
authorPablo Ariño Muñoz <progpabarino@gmail.com>
Tue, 25 Feb 2025 15:54:16 +0000 (16:54 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Wed, 26 Feb 2025 11:59:47 +0000 (11:59 +0000)
Signed-off-by: Pablo Ariño Muñoz <progpabarino@gmail.com>
src/gui/generalsettings.cpp
src/gui/generalsettings.h
src/gui/generalsettings.ui
src/libsync/configfile.cpp
src/libsync/configfile.h

index addcada5a1524818b956f7b9b11eab21523c518b..1307702239e2288819aa708b8230bdeb2ec8b2b6 100644 (file)
@@ -247,8 +247,7 @@ GeneralSettings::GeneralSettings(QWidget *parent)
     connect(_ui->stopExistingFolderNowBigSyncCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::saveMiscSettings);
     connect(_ui->newExternalStorage, &QAbstractButton::toggled, this, &GeneralSettings::saveMiscSettings);
     connect(_ui->moveFilesToTrashCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::saveMiscSettings);
-    connect(_ui->remotePollIntervalSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &GeneralSettings::slotRemotePollIntervalChanged);
-    connect(_ui->remotePollIntervalCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotRemotePollIntervalCheckBoxToggled);
+    connect(_ui->remotePollIntervalSpinBox, &QSpinBox::valueChanged, this, &GeneralSettings::slotRemotePollIntervalChanged);
 #ifndef WITH_CRASHREPORTER
     _ui->crashreporterCheckBox->setVisible(false);
 #endif
@@ -330,12 +329,9 @@ void GeneralSettings::loadMiscSettings()
     _ui->newExternalStorage->setChecked(cfgFile.confirmExternalStorage());
     _ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());
 
-    
-    bool hasCustomInterval = cfgFile.hasRemotePollInterval();
-    _ui->remotePollIntervalCheckBox->setChecked(hasCustomInterval);
+    ;
     auto interval = cfgFile.remotePollInterval(); 
     _ui->remotePollIntervalSpinBox->setValue(static_cast<int>(interval.count() / 1000));  
-    _ui->remotePollIntervalSpinBox->setEnabled(hasCustomInterval);
 }
 
 #if defined(BUILD_UPDATER)
@@ -654,31 +650,15 @@ void GeneralSettings::customizeStyle()
 #endif
 }
 
-void GeneralSettings::slotRemotePollIntervalCheckBoxToggled(bool checked) {
-    _ui->remotePollIntervalSpinBox->setEnabled(checked); // Enable/disable the spin box
-
-    ConfigFile cfgFile;
-
-    if (checked) {
-        slotRemotePollIntervalChanged(_ui->remotePollIntervalSpinBox->value());
-    } else {
-        // Reset to default interval when unchecked
-        cfgFile.resetRemotePollInterval();
-
-        // Update the spinbox with the default value
-        auto interval = cfgFile.remotePollInterval();
-        _ui->remotePollIntervalSpinBox->setValue(static_cast<int>(interval.count() / 1000));
-    }
-}
 
 void GeneralSettings::slotRemotePollIntervalChanged(int seconds) {
-    if (_currentlyLoading) return;
-
-    if (_ui->remotePollIntervalCheckBox->isChecked()) {
-        ConfigFile cfgFile;
-        std::chrono::milliseconds interval(seconds * 1000);
-        cfgFile.setRemotePollInterval(interval);
+    if (_currentlyLoading) {
+        return;
     }
+
+    ConfigFile cfgFile;
+    std::chrono::milliseconds interval(seconds * 1000);
+    cfgFile.setRemotePollInterval(interval);
 }
 
 } // namespace OCC
index 30d02cdf3e8817382237424cb328d56474f2b84a..7868c489999000de7e1c52a50d715c585729483b 100644 (file)
@@ -60,7 +60,6 @@ private slots:
     void loadMiscSettings();
     void slotShowLegalNotice();
     void slotRemotePollIntervalChanged(int seconds);
-    void slotRemotePollIntervalCheckBoxToggled(bool checked);
 #if defined(BUILD_UPDATER)
     void slotUpdateInfo();
     void slotUpdateChannelChanged();
index 1d79bd1f3224a989cdbe129caed047ff3a9a3687..0662b63ac3ae12f1efc8a37adf69dcbe8fc968d7 100644 (file)
          </widget>
         </item>
        </layout>
+      </item>      
+      <item>
+       <layout class="QHBoxLayout" name="horizontalLayout_trash">
+        <item>
+         <widget class="QCheckBox" name="moveFilesToTrashCheckBox">
+          <property name="text">
+           <string>Move removed files to trash</string>
+          </property>
+         </widget>
+        </item>
+       </layout>
       </item>
       <item>
        <layout class="QHBoxLayout" name="horizontalLayout_remotePollInterval">
         <item>
-         <widget class="QCheckBox" name="remotePollIntervalCheckBox">
+         <widget class="QLabel" name="remotePollIntervalLabel">
           <property name="text">
            <string>Server poll interval</string>
           </property>
             <number>30</number>
           </property>
           <property name="maximum">
-           <number>3600</number>
+           <number>999999</number>
           </property>
           <property name="singleStep">
            <number>1</number>
         </item>
        </layout>
       </item>
-      <item>
-       <layout class="QHBoxLayout" name="horizontalLayout_trash">
-        <item>
-         <widget class="QCheckBox" name="moveFilesToTrashCheckBox">
-          <property name="text">
-           <string>Move removed files to trash</string>
-          </property>
-         </widget>
-        </item>
-       </layout>
-      </item>
       <item>
        <layout class="QHBoxLayout" name="horizontalLayout_10">
         <item>
index 6adb8c2e2bbbc439a8e57eb7e141678011ab73f7..1efd01e5da355610138ca32bc0d81009222658d5 100644 (file)
@@ -1315,25 +1315,4 @@ void ConfigFile::setDiscoveredLegacyConfigPath(const QString &discoveredLegacyCo
     _discoveredLegacyConfigPath = discoveredLegacyConfigPath;
 }
 
-bool ConfigFile::hasRemotePollInterval(const QString &connection) const
-{
-    QString con(connection);
-    if (connection.isEmpty())
-        con = defaultConnection();
-
-    QSettings settings(configFile(), QSettings::IniFormat);
-    settings.beginGroup(con);
-
-    return settings.contains(QLatin1String(remotePollIntervalC));
-}
-
-void ConfigFile::resetRemotePollInterval(const QString &connection) {
-    QString con(connection);
-    if (connection.isEmpty())
-        con = defaultConnection();
-
-    std::chrono::milliseconds defaultInterval(DEFAULT_REMOTE_POLL_INTERVAL);
-    setRemotePollInterval(defaultInterval, con); // Use existing method
-}
-
 }
index bf6be3548ccb9cdae5d96932a3364b66a185047a..f38fba1f11ab047d1d9166a2b8081ed1feab0088 100644 (file)
@@ -153,8 +153,6 @@ public:
     [[nodiscard]] bool useNewBigFolderSizeLimit() const;
     [[nodiscard]] bool confirmExternalStorage() const;
     void setConfirmExternalStorage(bool);
-    [[nodiscard]] bool hasRemotePollInterval(const QString &connection = QString()) const;
-    void resetRemotePollInterval(const QString &connection = QString());
 
     /** If we should move the files deleted on the server in the trash  */
     [[nodiscard]] bool moveToTrash() const;